<html>
<head><meta charset="utf-8"><title>possible typo? · t-compiler/rust-analyzer · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/index.html">t-compiler/rust-analyzer</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/possible.20typo.3F.html">possible typo?</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="219618875"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/possible%20typo%3F/near/219618875" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> kev <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/possible.20typo.3F.html#219618875">(Dec 11 2020 at 15:25)</a>:</h4>
<p>On this line of text: <a href="https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/base_db/src/input.rs#L59">https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/base_db/src/input.rs#L59</a></p>
<p>Should it say, <code>as in the rustc compiler</code> instead of <code>as in the rust-lang proper</code> ?</p>



<a name="219619002"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/possible%20typo%3F/near/219619002" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> kev <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/possible.20typo.3F.html#219619002">(Dec 11 2020 at 15:26)</a>:</h4>
<p>Or maybe I'm parsing the sentence incorrectly. I believe it is trying to say that packages have names, to which we pass to the rustc compiler</p>



<a name="219619138"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/possible%20typo%3F/near/219619138" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/possible.20typo.3F.html#219619138">(Dec 11 2020 at 15:27)</a>:</h4>
<p>Hmm, I think that comment might be wrong</p>



<a name="219619149"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/possible%20typo%3F/near/219619149" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/possible.20typo.3F.html#219619149">(Dec 11 2020 at 15:27)</a>:</h4>
<p>But no, we don't pass anything to rustc</p>



<a name="219619275"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/possible%20typo%3F/near/219619275" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> kev <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/possible.20typo.3F.html#219619275">(Dec 11 2020 at 15:28)</a>:</h4>
<p>Oh, I thought cargo passed the package name to rustc? via the --extern flag?</p>



<a name="219619396"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/possible%20typo%3F/near/219619396" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/possible.20typo.3F.html#219619396">(Dec 11 2020 at 15:29)</a>:</h4>
<p>Yeah, and r-a's model tries to match that, which is what the comment is trying to say</p>



<a name="219619628"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/possible%20typo%3F/near/219619628" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/possible.20typo.3F.html#219619628">(Dec 11 2020 at 15:30)</a>:</h4>
<p><span class="user-mention silent" data-user-id="211727">Jonas Schievink</span> <a href="#narrow/stream/185405-t-compiler.2Fwg-rls-2.2E0/topic/possible.20typo.3F/near/219619138">said</a>:</p>
<blockquote>
<p>Hmm, I think that comment might be wrong</p>
</blockquote>
<p>The reason I think it's wrong is because Cargo sets <code>CARGO_CRATE_NAME</code> for every crate it is compiling (<a href="https://doc.rust-lang.org/cargo/reference/environment-variables.html#environment-variables-cargo-sets-for-crates">https://doc.rust-lang.org/cargo/reference/environment-variables.html#environment-variables-cargo-sets-for-crates</a>), so there <em>is</em> a canonical name for every crate. They just can be arbitrarily renamed when depended on, and <em>that</em> name is usually more important to rust-analyzer.</p>



<a name="219620187"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/possible%20typo%3F/near/219620187" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> kev <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/possible.20typo.3F.html#219620187">(Dec 11 2020 at 15:35)</a>:</h4>
<p>IIUC, so if I have a workspace with a local crate called "foo" and I download an external dependency crate from cargo called "foo". They will both have unique names?</p>



<a name="219620400"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/possible%20typo%3F/near/219620400" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/possible.20typo.3F.html#219620400">(Dec 11 2020 at 15:37)</a>:</h4>
<p>I don't know. I think they only have to have unique names if a crate depends on both of them.</p>



<a name="219620516"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/possible%20typo%3F/near/219620516" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> kev <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/possible.20typo.3F.html#219620516">(Dec 11 2020 at 15:38)</a>:</h4>
<p>Maybe the name is derived as {CRATE_TYPE}{PACKAGE_NAME}_{CHECKSUM}, since in 'target/deps' I see the usually see names as <code>libfoo-94e80d872615fc96</code></p>



<a name="219620582"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/possible%20typo%3F/near/219620582" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/possible.20typo.3F.html#219620582">(Dec 11 2020 at 15:39)</a>:</h4>
<p>yes, the will get unique file name hashes and lockfile entries</p>



<a name="219620590"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/possible%20typo%3F/near/219620590" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/possible.20typo.3F.html#219620590">(Dec 11 2020 at 15:39)</a>:</h4>
<p>but that isn't the crate name</p>



<a name="219620765"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/possible%20typo%3F/near/219620765" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> kev <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/possible.20typo.3F.html#219620765">(Dec 11 2020 at 15:40)</a>:</h4>
<p>Ahh right, my mistake</p>



<a name="219620851"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/possible%20typo%3F/near/219620851" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> kev <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/possible.20typo.3F.html#219620851">(Dec 11 2020 at 15:41)</a>:</h4>
<p>I'll leave a note on the comment and come back, as cargo is a bit out of scope right now :D</p>



<a name="219620886"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/possible%20typo%3F/near/219620886" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/possible.20typo.3F.html#219620886">(Dec 11 2020 at 15:42)</a>:</h4>
<p>Thar hash part is passed to rustc using <code>-Cextra-filename</code>. The full filename is derived as &lt;file prefix&gt;&lt;package name&gt;&lt;extra-filename&gt;&lt;file postfix&gt;. File prefix and postfix are dependent on the crate type and target. For example windows doesn't use the <code>lib</code> prefix.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>